<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <title>layout 后台大布局 - Layui</title>
    <link rel="stylesheet" href="/static/layui/css/layui.css">
    <link rel="stylesheet" href="/static/admin/css/common.css">
</head>
<body>
<div class=" body-main">
    <form class="layui-form" action="">
        <div class="layui-form-item">
            <label class="layui-form-label">用户名</label>
            <div class="layui-input-inline">
                <input type="text" name="username" lay-verify="required" placeholder="请输入" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">密码</label>
            <div class="layui-input-inline">
                <input type="password" name="password" lay-verify="required" placeholder="请输入" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">确认密码</label>
            <div class="layui-input-inline">
                <input type="password" name="password_confirm" lay-verify="required" placeholder="请输入" autocomplete="off" class="layui-input">
            </div>
        </div>

        <div class="layui-form-item">
            <div class="layui-inline">
                <label class="layui-form-label">手机</label>
                <div class="layui-input-inline">
                    <input type="tel" name="phone" lay-verify="required|phone" autocomplete="off" class="layui-input" placeholder="手机号码">
                </div>
            </div>
        </div>

        <div class="layui-form-item">
            <div class="layui-inline">
                <label class="layui-form-label">邮箱</label>
                <div class="layui-input-inline">
                    <input type="text" name="email" lay-verify="email" autocomplete="off" class="layui-input" placeholder="邮箱">
                </div>
            </div>
        </div>

        <div class="layui-form-item">
            <div class="layui-input-block">
                <button class="layui-btn" lay-submit="" lay-filter="save_admin">立即提交</button>
            </div>
        </div>
    </form>
</div>
<script src="/static/layui/layui.js"></script>
<script>
    layui.config({
        base : "/static/js/"
    }).use(['form','layer','jquery','common','carousel', 'element'], function () {
        var $ = layui.jquery,
            form = layui.form,
            common = layui.common,
            carousel = layui.carousel;

        form.render(); //更新全部

        /**监听登陆提交*/
        form.on('submit(save_admin)', function (data) {
            //弹出loading
            var loginLoading = top.layer.msg('正在提交', {icon: 16, time: false, shade: 0.8});
            //记录ajax请求返回值
            var ajaxReturnData;

            console.log(data);

            //登陆验证
            $.ajax({
                url: common.apiUrl('save_admin'),
                type: 'post',
                async: false,
                data: data.field,
                success: function (data) {
                    console.log(data);
//                    ajaxReturnData = data;
                }
            });
//            return false;
            //登陆成功
//            if (ajaxReturnData.code == 0000) {
//                window.location.href="index.do";
//                top.layer.close(loginLoading);
//                return false;
//            } else {
//                top.layer.close(loginLoading);
//                common.cmsLayErrorMsg(ajaxReturnData.msg);
//                reqCaptcha();
//                return false;
//            }
        });
    });
</script>
</body>
</html>